package cn.ecnu.auction.service;



import org.json.JSONObject;

import cn.ecnu.auction.dao.GoodsDAO;
import cn.ecnu.auction.engine.IService;
import cn.ecnu.auction.engine.Context;
import cn.ecnu.auction.po.Goods;

public class GoodsService implements IService{
	
	public void executeService(Context context) throws Exception {
		
		JSONObject requestJson = context.getJsonRequestObject();
		String operation = requestJson.getString("operation");
		int returnValue = 0;
		String jsonString = null;
		int returnCode = 0;
		
		if(operation.equals("add")){
			//新增拍卖品
			String gname = requestJson.getString("gname");
			String description = requestJson.getString("description");
			double startPrice = requestJson.getDouble("startPrice");
			double startTime = requestJson.getDouble("startTime");
			double lastingTime = requestJson.getDouble("lastingTime");
			
			returnValue = new GoodsDAO().addGood(gname, description, startPrice, startTime, lastingTime);
		}
		else if(operation.equals("")){
			
		}
		//返回值
		JSONObject o = new JSONObject();
		o.put("returnCode", returnCode);
		o.put("returnValue", returnValue);
		context.setJsonResponseObject(o);
	}
}
